﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace WPFByCoreApp
{
    public class TestException
    {
        public static void Test()
        {
            var types = GetChildTypes(typeof(SystemException));
            types.ToList().ForEach(par => {

                Debug.WriteLine(par.Name);
            });


            try
            {
                decimal.Parse("sdfsdfsdfsfas");
            }
            catch (System.NullReferenceException ex)
            {
                
            }
        }


        public static Type[] GetChildTypes(Type parentType)

        {

            List<Type> lstType = new List<Type>();

            Assembly assem = Assembly.GetAssembly(parentType);

            foreach (Type tChild in assem.GetTypes())

            {

                if (tChild.BaseType == parentType)

                {

                    lstType.Add(tChild);

                }

            }

            return lstType.ToArray();

        }
    }
}
